# Importing Data
JAPAN<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Aluminium/Aluminium.xlsx",sheet = "Sheet1", range = "V1:V229")

# Checking the Imported Data
View(JAPAN)
# Creating Time Series Data
JAPAN_ts <- ts(JAPAN, start=c(1999,1), end=c(2015,12), frequency=12)
# Viewing and Checking the Created Time Series Data
JAPAN_ts
sum(is.na(JAPAN_ts))
library(forecast)
JAPAN_ts <- tsclean(JAPAN_ts)
JAPAN_ts

# Identification: Plotting the Time Series Data
plot(JAPAN_ts)

# Estimating the appropriate model
JAPAN_ts_model <- auto.arima(JAPAN_ts)
JAPAN_ts_model

# Forecasting
options(max.print=1000000)
JAPAN_ts_forecast <- forecast (JAPAN_ts_model, level=c(95), h=300)
plot(JAPAN_ts_forecast)
JAPAN_ts_forecast             

# Exporting
write.table(JAPAN_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Aluminium/JAPAN_TSA.csv", sep=",")
